#include<iostream>
using namespace std;

int coins[20001];
int T[20001];
int buf[20001];

int Min(int a, int b){
	return a>b? b: a;
} 

int MinCoin(int n, int m){
	for (int i = 0; i <= m; i++){
		buf[i] = i+1;
	}
	buf[0] = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < coins[i]; j++){
			for (int k = m-T[i]; k >= 0; k--){
				if (buf[k] <= k){
					buf[k+T[i]] = Min(buf[k+T[i]], buf[k]+1);
				}
			}
		}
	}
	return buf[m]>m? -1: buf[m];
}
int main(){
	int n, m;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> T[i] >> coins[i];
	}
	cin >> m;
	cout << MinCoin(n, m) << endl;
	return 0;
}
